home *** CD-ROM | disk | FTP | other *** search
-
- XDEF StrToNum
-
- XREF StrLen
-
- ; Returns the decimal value of the string in A0 in D0.
- ; Only works for values 0-99999
-
- StrToNum:
- move.l a0,-(sp)
- bsr StrLen
- move.l (sp)+,a0
- tst.l d0
- bne .Cont
- rts
-
- .Cont:
- moveq #0,d2 ; Converted number.
- moveq #1,d3 ; 10 Multiplier.
- move.l d0,d1
- subq.l #1,d1 ; Conversion loop reg.
- subq.l #1,d0
- add.l d0,a0
- moveq #0,d0
-
- .Loop:
- move.b (a0),d0
- sub.b #"0",d0
- and.w #$ff,d0
- mulu.w d3,d0
- add.l d0,d2
- mulu.w #10,d3
- subq.l #1,a0
- dbf d1,.Loop
- move.l d2,d0
- rts
-